import os
import re

def modify_paths(input_file, input_dir):
    # current_dir = os.path.dirname(os.path.abspath(__file__))
    with open(input_file, 'r', encoding='utf-8') as f:
        lines = f.readlines()
    
    with open(input_file, 'w', encoding='utf-8') as f:
        for line in lines:
            # 提取文件名和标签
            parts = line.strip().split('\t')
            if len(parts) == 2:
                filename = os.path.basename(parts[0])
                new_path = os.path.join(input_dir, filename)

                f.write(f"{new_path}\t{parts[1]}\n")
            else:
                f.write(line)

# 使用示例
input_dir = r"D:\songlin\data\9.公开数据集\身份证号识别\IDcard"
modify_paths("fileState.txt", input_dir)